<template>
	<view class="all">
		<view class="carp">
			<text class="carp_1 logo1">设置密码</text>
			<text class="carp_2">Set password</text>
			<view style="margin-top: 50rpx;">
				<view class="imput">
					<image class='logo2' style="width: 38rpx;" src="@/static/img/mima1.png" />
					<view style="width: 90%;">
						<u-input type="password" v-model="from.password" placeholder="请输入新密码" />
					</view>
				</view>
				<view class="imput">
					<image class='logo2' style="width: 38rpx;" src="@/static/img/mima1.png" />
					<view style="width: 90%;">
						<u-input type="password" v-model="from.newpassword" placeholder="确认新的密码" />
					</view>
				</view>
			</view>
			<text class="denglu" @click="submit('确定')">确定</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				from: {
					password: '',
					newpassword: '',
					mobile: '',
				},
			};
		},
		onLoad(a) {
			this.from.mobile = a.mobile
		},
		methods: {
			submit(a) {
				if (a == '确定') {
					if (!this.from.password) {
						this.$toast("请输入密码", 0)
						return
					}
					if (!this.from.newpassword) {
						this.$toast("请确定密码", 0)
						return
					}
					this.$api('user/resetpwd', this.from).then(res => {
						if (res.code == 1) {
							// uni.setStorage({
							// 	key: 'token',
							// 	data: res.data.token
							// })
							this.$toast(res.msg, 1)
							setTimeout(() => {
								uni.redirectTo({
									url: './login'
								})
							}, 1000)

						} else {
							this.$toast(res.msg, 0)
						}
					})

				}
			}
		}
	}
</script>

<style lang="scss">
	.carp {
		width: 75%;
		margin: auto;

		.hqy {
			border-left: 1rpx solid #E3E3E3;
			;
			padding-left: 30rpx;
			display: block;
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #131314;
			opacity: 1;

		}

		.qita {
			margin-top: 150rpx;

			.qita_1 {
				text-align: center;
				margin-top: 40rpx;

				image {
					width: 60rpx;
					height: 50rpx;
				}
			}
		}

		.my {
			text-align: center;
			padding-top: 20rpx;

			text:nth-of-type(1) {
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #131314;
				opacity: 1;
			}

			text:nth-of-type(2) {
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #FFD500;
				opacity: 1;

			}
		}

		.denglu {
			margin-top: 180rpx;
			display: block;
			width: 562rpx;
			height: 88rpx;
			background: #131314;
			opacity: 1;
			border-radius: 4rpx;
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			text-align: center;
			line-height: 88rpx;
			font-weight: 400;
			color: #FFFFFF;
			opacity: 1;
		}

		.wangji {
			text-align: right;
			display: block;
			padding-top: 20rpx;
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #91969A;
			opacity: 1;
		}

		.imput {
			border-bottom: 1rpx solid #E3E3E3;
			padding: 40rpx 0 10rpx 0;
			display: flex;
			justify-content: space-between;
			align-items: center;

			image {
				width: 30rpx;
				height: 44rpx;
			}
		}

		.carp_2 {
			font-size: 30rpx;
			display: inline-block;
			margin-top: 10rpx;
			font-family: HarmonyOS Sans;
			font-weight: 400;
			color: #91969A;
			opacity: 1;
		}

		.carp_1 {
			margin-top: 40rpx;
			display: block;
			font-size: 36rpx;
			font-family: Source Han Sans CN;
			font-weight: bold;
			color: #131314;
			opacity: 1;

		}

		.logo1 {
			margin-top: 200rpx;
		}
	}
</style>
